import request from './request'

/**
 * 获取分类列表
 * @param {*} params
 * @returns
 */
export const getSortList = (params) => {
  return request({
    url: '/sort/list',
    params
  })
}

/**
 * 新增分类
 * @param {*} data
 * @returns
 */
export const addSort = (data) => {
  return request({
    url: '/sort/add',
    method: 'post',
    data
  })
}

/**
 * 修改分类
 * @param {*} data
 * @returns
 */
export const updateSort = (data) => {
  return request({
    url: '/sort/update',
    method: 'put',
    data
  })
}

/**
 * 根据Id删除分类
 * @param {*} id
 */
export const deleteSort = (id) => {
  return request({
    url: `/sort/${id}`,
    method: 'delete'
  })
}

/**
 * 根据分类Id查询标签列表
 * @returns
 */
export const getSortTagList = (id) => {
  return request({
    url: `/sortTag/list/${id}`
  })
}

/**
 * 新增分类关联标签
 * @param {*} data
 * @returns
 */
export const addSortTag = (data) => {
  return request({
    url: '/sortTag/add',
    method: 'post',
    data
  })
}

/**
 * 根据Id删除分类关联标签
 * @param {*} sort_id
 * @param {*} tag_id
 * @returns
 */
export const deletesortTag = (sort_id, tag_id) => {
  return request({
    url: `sortTag/delete`,
    method: 'post',
    data: {
      sort_id,
      tag_id
    }
  })
}

/**
 * 根据目录Id查询分类列表
 * @param {*} params
 * @returns
 */
export const getSortLsitByCatalogId = (params) => {
  return request({
    url: '/sort/list/catalogid',
    params
  })
}
